//
//  ErrorDelegate.m
//  cTypica
//
//  Created by David Kavanagh on 11/25/08.
//  Copyright 2008 directThought. All rights reserved.
//

#import "ErrorDelegate.h"

@implementation ErrorDelegate
@synthesize message, code, requestId;

+ (id)delegate {
	ErrorDelegate *ret = [self alloc];
	return ret;
}

// XML parser delegate methods
- (void)parser: (NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
}

- (void)parser: (NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
	NSString *cleanString = [currentStringValue stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
	[currentStringValue setString:@""];
	if ([elementName isEqualToString:@"Message"]) {
		[self setMessage:cleanString];
	}
	else if ([elementName isEqualToString:@"Code"]) {
		[self setCode:cleanString];
	}
	else if ([elementName isEqualToString:@"RequestId"]) {
		[self setRequestId:cleanString];
	}
}
@end
